<template>
	<view class="classification__container">
		<view class="classification__top">
			<view class="classification__top__name">{{category.categoryName}}</view>
			<view class="classification__top__utils" @click="isExpand=!isExpand">
				<cover-view>{{isExpand?'收起':'展开'}}</cover-view>
				<Icon class="jiantouzuo" href="jiantouzuo"/>
			</view>
		</view>
		<view class="classification__main">
			<view class="classification__item" v-for="item in list">{{item.name}}</view>
		</view>
	</view>
</template>

<script setup>
	import Icon from '@/common/components/Icon/index.vue';
	import {ref,computed} from 'vue';
	const props = defineProps({
		category:{
			type:Object,
			required:true,
		}
	});
	// 是否展开
	const isExpand = ref(false)
	
	let list = computed(()=>{
		if(!isExpand.value){// 不展开
			return props.category.data.slice(0,30)
		}
		return props.category.data;
	})
</script>

<style lang="scss">
	
	.classification__container{
		
		padding:30rpx 20rpx;
		.classification__top{
			display: flex;
			align-items: center;
			justify-content: space-between;
			// padding: 20rpx 0;
			padding-bottom: 20rpx;
			.classification__top__utils{
				display: flex;
				align-items: center;
			}
			.classification__top__name{
				font-size: 30rpx;
				font-weight: bold;
				color: #b0b0b0;
			}
			.jiantouzuo{
				width: 30rpx;
				height: 30rpx;
			}
		}
	
		.classification__main{
			display: grid;
			grid-template-columns: repeat(3,1fr);
			gap: 20rpx;
		}
		.classification__item{
			padding: 20rpx 0;
			text-align: center;
			background-color: #f7f7f7;
			border-radius: 4rpx;
			white-space: nowrap;
			font-size: 30rpx;
		}
	}
	
</style>